Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/classnames
Advanced tools
Stub TypeScript definitions entry for classnames, which provides its own types definitions
The @types/classnames package provides TypeScript type definitions for the classnames library, which is a utility for conditionally joining classNames together. This package is useful for TypeScript users who want to ensure type safety when using classnames to dynamically generate class strings based on certain conditions.
Basic usage with strings
Combine multiple class names into a single string.
classNames('foo', 'bar'); // 'foo bar'
Using objects to conditionally apply classes
Apply classes based on the truthiness of the associated value.
classNames({ 'foo': true, 'bar': false }); // 'foo'
Combining types
Mix strings and objects to conditionally apply classes.
classNames('foo', { 'bar': true }, 'baz', { 'qux': false }); // 'foo bar baz'
Using arrays
Pass arrays of class names to be joined together.
classNames(['foo', 'bar'], ['baz']); // 'foo bar baz'
clsx is a tiny utility for constructing className strings conditionally. It is similar to classnames but offers a more optimized, faster implementation with a smaller footprint.
Emotion is a performant and flexible CSS-in-JS library. While primarily focused on styling components, it includes the `cx` function, which is similar to classnames for combining class names based on conditions.
This is a stub types definition for @types/classnames (https://github.com/JedWatson/classnames#readme).
classnames provides its own type definitions, so you don't need @types/classnames installed!
FAQs
Stub TypeScript definitions entry for classnames, which provides its own types definitions
We found that @types/classnames demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.